<template>
	<view class="real">
		<Navbar>实名认证</Navbar>
		<scroll-view scroll-y class="scroll_view">
			<view class="box" v-if="real">
				<view class="cover">已认证</view>
				<view class="item">姓名：{{real_name}}</view>
				<view class="item">身份证：{{real_card}}</view>
			</view>
			<view class="content" v-else>
				<view class="title">
					<view>
						<image :src="`${baseImageUrl}/common/zw.png`"></image>
						<text>认证信息</text>
						<image :src="`${baseImageUrl}/common/zw.png`"></image>
					</view>
				</view>
				<view class="item">
					<view class="key">姓名</view>
					<input type="text" placeholder="请输入姓名" class="input" v-model="real_name">
				</view>
				<view class="item">
					<view class="key">身份证</view>
					<input type="text" placeholder="请输入身份证号码" class="input" v-model="real_card">
				</view>
				<view class="btn" @click="submit">认证</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import {
		userRealname
	} from '@/request/api.js';
	export default {
		data() {
			return {
				real: false,

				real_name: "",
				real_card: ""
			}
		},
		onLoad(option) {
			let is = option.is;
			if (is > 0) {
				this.real_name = this.$store.state.info.real_name;
				this.real_card = this.$store.state.info.real_card;
				this.real = true;
			}
		},
		methods: {
			async submit() {
				await userRealname({
					real_name: this.real_name,
					real_card: this.real_card,
				});
				this.$u.toast("认证成功");
				setTimeout(() => {
					this.backRouter();
				}, 1000);
			}
		}
	}
</script>

<style scoped lang="scss">
	.real {
		height: 100vh;
		background: #29170D;
		overflow: hidden;

		.scroll_view {
			height: calc(100vh - #{$navbarHeight});
			padding-top: 48rpx;
			box-sizing: border-box;

			.box {
				width: 688rpx;
				height: 606rpx;
				margin: 0 auto;
				padding: 42rpx 54rpx 50rpx;
				box-sizing: border-box;
				background: url(#{$baseImageUrl}/bg/688_606.png) no-repeat;
				background-size: 100% 100%;
				display: flex;
				flex-direction: column;

				.cover {
					width: 200rpx;
					height: 200rpx;
					color: #38880F;
					font-size: 40rpx;
					font-weight: 400;
					font-family: LiSu;
					margin: 0 auto;
					background: url(#{$baseImageUrl}/common/unlock_success.png) no-repeat;
					background-size: 100% 100%;
					display: flex;
					justify-content: center;
					align-items: flex-end;
				}

				.item {
					color: #494338;
					font-size: 28rpx;
					font-weight: 400;
					font-family: SimSun;
					margin-top: 40rpx;
				}
			}

			.content {
				width: 688rpx;
				height: 606rpx;
				margin: 0 auto;
				padding: 42rpx 54rpx 50rpx;
				box-sizing: border-box;
				background: url(#{$baseImageUrl}/bg/688_606.png) no-repeat;
				background-size: 100% 100%;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				align-items: center;

				.title {
					display: flex;
					justify-content: center;
					align-items: center;

					view {
						height: 30rpx;
						display: flex;
						align-items: center;

						image {
							width: 30rpx;
							height: 30rpx;
						}

						text {
							color: #494338;
							font-size: 42rpx;
							font-weight: 400;
							font-family: LiSu;
							margin: 0 10rpx;
						}
					}
				}

				.item {
					width: 100%;

					.key {
						color: #494338;
						font-size: 32rpx;
						font-weight: 400;
						font-family: SimSun;
						margin-bottom: 20rpx;
					}

					.input {
						width: 100%;
						height: 80rpx;
						border-radius: 10rpx;
						padding-left: 45rpx;
						box-sizing: border-box;
						box-shadow: 2rpx -1px 10rpx 0px rgba(3, 0, 0, 0.2);
						background: #C0B5B6;
					}
				}

				.btn {
					width: 204rpx;
					height: 74rpx;
					line-height: 74rpx;
					text-align: center;
					color: #FFFFFF;
					font-size: 30rpx;
					font-weight: 400;
					font-family: SimSun;
					background: url(#{$baseImageUrl}/common/btn.png) no-repeat;
					background-size: 100% 100%;
				}
			}
		}
	}
</style>